<?php
/**
 * @author Bach Vu (lebachvu@gmail.com)
 * @copyright 2012
 */
include "header.php";

#check session
if (isset($_SESSION["Login"]["user_name"]))
{
################################################################################################################
## Start check session
################################################################################################################	
	$id = $_GET["id"];
	
	$query = "select * from products where id=$id";
	
	#echo $query;
	
	$product = $DB->QueryRow($query);
	
	$count = $DB->rows;		
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Thông tin sản phẩm</title>
</head>

<body>

<?php
    echo "Welcome, ". $_SESSION["Login"]["user_name"]. " [ <a href='logout.php'>logout</a> ]<br/>";
?>
    
<form id="form1" name="form1" method="post" action="productact.php" enctype="multipart/form-data">
	<input name="id" type="hidden" value="<?php echo($id) ?>"/>
  <table width="100%" border="0" cellspacing="0" cellpadding="4">  
    <tr>      
      <td colspan="2"><h3>Thông tin sản phẩm</h3></td>
    </tr>
    <tr align="left">
      <th scope="row" width="250px">Tên sản phẩm</th>
      <td><input id="name" name="name" type="text" value="<?php echo($product["name"])?>"/></td>
    </tr>
    <tr align="left">
      <th scope="row">Hình ảnh</th>
      <td><input id="picture" name="picture" type="file"/></td>
    </tr>
    <tr align="left">
      <th scope="row">Trị giá</th>
      <td><input id="price" name="price" type="text" value="<?php echo($product["price"])?>"/></td>
    </tr>
    <tr align="left">
      <th scope="row">Đặc biệt</th>
      <td><input id="special" name="special" type="text" value="<?php echo($product["special"])?>"/></td>
    </tr>
    <tr align="left">
      <th scope="row">Giá giảm</th>
      <td><input id="selloff" name="selloff" type="text" value="<?php echo($product["selloff"])?>"/></td>
    </tr>
    <tr align="left">
      <th scope="row">Ngày sản xuất</th>
      <td><input id="publish_date" name="publish_date" type="text" value="<?php echo($product["publish_date"])?>"/></td>
    </tr>
    <tr align="left">
      <th scope="row">Mô tả ngắn</th>
      <td><textarea name="scontent"><?php echo($product["synopsis"])?></textarea></td>
    </tr>
    <tr align="left">
      <th scope="row">Xuất sứ</th>
      <td><input name="author" type="text" value="<?php echo($product["author"])?>"/></td>
    </tr>    
    <tr align="left">
      <th scope="row">Mô tả chi tiết</th>
      <td>
   		<textarea name="lcontent"><?php echo($product["content"])?></textarea>
      </td>
    </tr>
    <tr align="left">
      <th scope="row">Số lần xem</th>
      <td><input name="hits" type="text" value="<?php echo($product["hits"])?>"/></td>
 </tr>
     <tr align="left">
      <th scope="row">Thứ tự</th>
      <td><input name="order" type="text" value="<?php echo($product["order"])?>"/></td>
    </tr>
     <tr align="left">
      <th scope="row">Trang thái</th>
      <td><input name="status" type="checkbox" title="Hiển thị sản phẩm"/></td>
    </tr>
     <tr align="left">
      <th scope="row">Loại sản phẩm</th>
      <td>
        <?php 
            select_category('cat_id', $product['cat_id'], $DB);                  
           	#include "product_category.php";
		?>
      </td>
    </tr>
    <tr align="left">
      <th scope="row"></th>
      <td>
      	<input type="submit" name="submit" value="   Thêm   "/>
      </td>
    </tr>
  </table>
</form>
</body>
</html>

<?php
################################################################################################################
## End check session
################################################################################################################
} 
else
{
	header("Location: index.php");	
}

?>